﻿using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NCP.Util
{
    public class JsonHelp
    {
        /// <summary>
        /// 转Json，格式化时间yyyy-MM-dd
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static string SerializeObject(object obj, string DateTimeFormat = "yyyy-MM-dd")
        {
            var iso = new IsoDateTimeConverter();
            iso.DateTimeFormat = DateTimeFormat;

            return JsonConvert.SerializeObject(obj, iso);
        }
    }
}
